# Maintainer: Miles Alan <m@milesalan.com>
pkgname=mepo
pkgver=1.3.3
pkgrel=0
pkgdesc="Fast, simple, and hackable OSM map viewer for Linux"
url="https://git.sr.ht/~mil/mepo"
arch="aarch64 x86_64" # Limited by zig aport
license="GPL-3.0-or-later"
makedepends="
	curl-dev
	sdl2-dev
	sdl2_gfx-dev
	sdl2_image-dev
	sdl2_ttf-dev
	zig>=0.13.0
	"
depends="
	zenity
	curl
	xwininfo
	geoclue
	jq
	ncurses
	font-hack-nerd
"
source="
	$pkgname-$pkgver.tar.gz::https://git.sr.ht/~mil/mepo/archive/$pkgver.tar.gz
	"
subpackages="
	$pkgname-doc
"

# We may want other than "baseline" for other targets, when enabled by zig
case "$CARCH" in
	aarch64|x86_64) cputarget=baseline ;;
esac

build() {
	zig build -Doptimize=ReleaseSafe ${cputarget:+-Dcpu="$cputarget"}
	zig-out/bin/mepo -docmd > doc.md
}

check() {
	zig build test
}

package() {
	install -Dm755 zig-out/bin/mepo* -t "$pkgdir/usr/bin/"
	install -Dm755 scripts/mepo* -t "$pkgdir/usr/bin/"
	install -Dm644 zig-out/share/applications/mepo.desktop -t "$pkgdir/usr/share/applications/"
	install -Dm644 zig-out/share/pixmaps/mepo.png -t "$pkgdir/usr/share/pixmaps/"
	install -Dm644 doc.md -t "$pkgdir"/usr/share/doc/"$pkgname"/
}
sha512sums="
9d5b1c7dc411c9d5258753d3c43b4ba55d6b460044fbd3a8872f4532f5b3472123b43368910a46724bcce238d19e66dfd552810a96cb16bf84f67f04b1f6b2e4  mepo-1.3.3.tar.gz
"
